package com.itheima.socket.tcp.demo05;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo05 {

    public static void main(String[] args) throws IOException {

        ServerSocket serverSocket = new ServerSocket(2222);
        Socket socket = serverSocket.accept();
        System.out.println("连接已经建立了......");
        InputStream inputStream = socket.getInputStream();
        byte[] bytes = new byte[1024];
        System.out.println("要开始读数据了......");
        int read = inputStream.read(bytes);
        System.out.println("读取到数据了.....");
        System.out.println(new String(bytes, 0, read));
        socket.close();
        serverSocket.close();
    }
}
